package evm

import (
	"math/big"
	"os"

	evmcom "hundsun.com/hsl/hschain/contract/evm/ext/common"
	"hundsun.com/hsl/hschain/contract/evm/ext/params"
	"hundsun.com/hsl/hschain/contract/evm/vm"
)

// NewDefaultChainConfig new default chain config
func NewDefaultChainConfig() *params.ChainConfig {
	return &params.ChainConfig{
		ChainID:             big.NewInt(1),
		HomesteadBlock:      big.NewInt(0),
		DAOForkBlock:        big.NewInt(0),
		DAOForkSupport:      true,
		EIP150Block:         big.NewInt(0),
		EIP150Hash:          evmcom.Hash{},
		EIP155Block:         big.NewInt(0),
		EIP158Block:         big.NewInt(0),
		ByzantiumBlock:      big.NewInt(0),
		ConstantinopleBlock: big.NewInt(0),
		PetersburgBlock:     big.NewInt(0),
		IstanbulBlock:       big.NewInt(0),
		MuirGlacierBlock:    big.NewInt(0),
		BerlinBlock:         big.NewInt(0),
		LondonBlock:         big.NewInt(0),
	}
}

// NewEvmConfig new evm config
func NewEvmConfig(noBaseFee, debug bool) *vm.Config {
	cfg := &vm.Config{
		NoBaseFee: noBaseFee,
		Debug:     debug,
	}
	//exec.vmCfg.Tracer = runtime.NewJSONLogger(os.Stdout)
	cfg.Tracer = vm.NewMarkdownLogger(
		&vm.LogConfig{
			DisableMemory:     false,
			DisableStack:      false,
			DisableStorage:    false,
			DisableReturnData: false,
			Debug:             debug,
			Limit:             0,
		},
		os.Stdout,
	)
	return cfg
}
